package com.yc.mybatis.core;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

//单例模式
public class MyProperties extends Properties{
	private static MyProperties myProp;
	
	//构造函数私有化
	private MyProperties() {
		
		try {
			//先得到io流
			InputStream is = new FileInputStream(new File("db.properties"));
			//通过io流，来加载数据
			this.load(is);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	public static MyProperties getInstance() {
		if( myProp == null ) {
			myProp = new MyProperties();
		}
		return myProp;
	}
}
